//
//  WPStatusCell.swift
//  WB
//
//  Created by 汪鹏 on 2017/1/6.
//  Copyright © 2017年 汪鹏. All rights reserved.
//

import UIKit

class WPStatusCell: UITableViewCell {

    // 用户头像
    @IBOutlet weak var iconView: UIImageView!
    // 用户名
    @IBOutlet weak var nameView: UILabel!
    // 显示vip
    @IBOutlet weak var vipView: UIImageView!
    // 时间
    @IBOutlet weak var timeView: UILabel!
    // 来源
    @IBOutlet weak var sourceView: UILabel!
    // 认证
    @IBOutlet weak var centiferView: UIImageView!
    // 正文
    @IBOutlet weak var textView: UILabel!
    // 底部工具栏
    @IBOutlet weak var statusBottomToolbar: WPStatusBottomToolbar!
    // 配图视图
    @IBOutlet weak var statusPictureView: WPStatusPictureView!
    
    @IBOutlet weak var retweeted_status_text: UILabel?
    // 视图模型
    var viewModel: WPSingleWBViewModel? {
        
        didSet{
            
            nameView.text = viewModel?.statu.user?.screen_name
            
            textView.text = viewModel?.statu.text
            
            vipView.image = viewModel?.vipIcon
            
            centiferView.image = viewModel?.verifierIcon
            
            iconView.wp_setImage(urlString: viewModel?.statu.user?.profile_image_url, placeholderImage: "avatar_default_big",isIcon: true)
            
            statusBottomToolbar.viewModel = viewModel
            
            statusPictureView.viewModel = viewModel
            
            statusPictureView.urls = viewModel?.pic_urls
            
            retweeted_status_text?.text = viewModel?.retweeted_statu_text
            
            sourceView.text = viewModel?.statu.source // viewModel?.sourceText
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        // 离屏渲染---异步绘制
        layer.drawsAsynchronously = true
        
        // 栅格化
        layer.shouldRasterize = true
        
        // 设置分辨率
        layer.rasterizationScale = UIScreen.main.scale
        
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
